//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: FetchingStorageRecordEventArgs.cs
//
//  Description: EventArgs used by the PersistentTypeSelector delegate.
// 
//--------------------------------------------------------------------------

using System;
using System.Data;

namespace Chili.Opf3
{
	/// <summary>
	/// EventArgs used in the
	/// <see cref="PersistentTypeSelector">PersistentTypeSelector</see> delegate and events using the
	/// <see cref="PersistentTypeSelector">PersistentTypeSelector</see> delegate. 
	/// </summary>
	/// <remarks>
	/// This EventArgs class is used in the 
	/// <see cref="PersistentTypeSelector">PersistentTypeSelector</see> delegate and events using the
	/// <see cref="PersistentTypeSelector">PersistentTypeSelector</see> delegate. 
	/// Some examples for the usage of this class are:
	/// <see cref="ObjectReader{T}.FetchingStorageRecord">FetchingStorageRecord</see> of the 
	/// <see cref="ObjectReader{T}">ObjectReader</see>, 
	/// <see cref="ObjectSet{T}.FetchingStorageRecord">FetchingStorageRecord</see> of the 
	/// <see cref="ObjectSet{T}">ObjectSet</see>, 
	/// <see cref="Opf3.Relations.ObjectSetHolder{T}.FetchingStorageRecord">FetchingStorageRecord</see> of the 
	/// <see cref="Opf3.Relations.ObjectSetHolder{T}">ObjectSetHolder</see> and
	/// <see cref="Opf3.Relations.ObjectHolder{T}.FetchingStorageRecord">FetchingStorageRecord</see> of the 
	/// <see cref="Opf3.Relations.ObjectHolder{T}">ObjectHolder</see> class.
	/// </remarks>
	public sealed class FetchingStorageRecordEventArgs : EventArgs
	{
		private IDataRecord _dataRecord;
		private Type _type;
		private bool _ignore;

		/// <summary>
		/// Creates a new instance of the 
		/// <see cref="FetchingStorageRecordEventArgs">FetchingStorageRecordEventArgs Class</see>.
		/// </summary>
		/// <param name="dataRecord">The current record (row or item) of the storage.</param>
		/// <param name="type">The current type of the persistent object to create.</param>
		internal FetchingStorageRecordEventArgs(IDataReader dataRecord, Type type)
		{
			_dataRecord = dataRecord;
			_type = type;
		}

		/// <summary>
		/// Specifies the type of the persistent object that is created.
		/// </summary>
		public Type Type
		{
			get { return _type; }
			set { _type = value; }
		}

		/// <summary>
		/// Returns the current <see cref="IDataRecord">IDataRecord</see> representing the current
		/// row or item of the storage.
		/// </summary>
		public IDataRecord DataRecord
		{
			get { return _dataRecord; }
		}

		/// <summary>
		/// Specifies whether to ignore the current row or item of the storage. Ignoring the current means
		/// that no persistent object is created and the framework tries to process the next item.
		/// </summary>
		public bool Ignore
		{
			get { return _ignore; }
			set { _ignore = value; }
		}
	}
}
